/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package spem.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import spem.Activity;
import spem.RoleDefinition;
import spem.SpemPackage;
import spem.TaskDefinition;
import spem.Tool;
import spem.WorkProductDefinition;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Activity</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link spem.impl.ActivityImpl#getWps <em>Wps</em>}</li>
 *   <li>{@link spem.impl.ActivityImpl#getTs <em>Ts</em>}</li>
 *   <li>{@link spem.impl.ActivityImpl#getRs <em>Rs</em>}</li>
 *   <li>{@link spem.impl.ActivityImpl#getTools <em>Tools</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ActivityImpl extends ElementImpl implements Activity {
	/**
	 * The cached value of the '{@link #getWps() <em>Wps</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getWps()
	 * @generated
	 * @ordered
	 */
	protected EList<WorkProductDefinition> wps;

	/**
	 * The cached value of the '{@link #getTs() <em>Ts</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTs()
	 * @generated
	 * @ordered
	 */
	protected EList<TaskDefinition> ts;

	/**
	 * The cached value of the '{@link #getRs() <em>Rs</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRs()
	 * @generated
	 * @ordered
	 */
	protected EList<RoleDefinition> rs;

	/**
	 * The cached value of the '{@link #getTools() <em>Tools</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTools()
	 * @generated
	 * @ordered
	 */
	protected EList<Tool> tools;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ActivityImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return SpemPackage.Literals.ACTIVITY;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<WorkProductDefinition> getWps() {
		if (wps == null) {
			wps = new EObjectContainmentEList<WorkProductDefinition>(WorkProductDefinition.class, this, SpemPackage.ACTIVITY__WPS);
		}
		return wps;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<TaskDefinition> getTs() {
		if (ts == null) {
			ts = new EObjectContainmentEList<TaskDefinition>(TaskDefinition.class, this, SpemPackage.ACTIVITY__TS);
		}
		return ts;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<RoleDefinition> getRs() {
		if (rs == null) {
			rs = new EObjectContainmentEList<RoleDefinition>(RoleDefinition.class, this, SpemPackage.ACTIVITY__RS);
		}
		return rs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Tool> getTools() {
		if (tools == null) {
			tools = new EObjectContainmentEList<Tool>(Tool.class, this, SpemPackage.ACTIVITY__TOOLS);
		}
		return tools;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case SpemPackage.ACTIVITY__WPS:
				return ((InternalEList<?>)getWps()).basicRemove(otherEnd, msgs);
			case SpemPackage.ACTIVITY__TS:
				return ((InternalEList<?>)getTs()).basicRemove(otherEnd, msgs);
			case SpemPackage.ACTIVITY__RS:
				return ((InternalEList<?>)getRs()).basicRemove(otherEnd, msgs);
			case SpemPackage.ACTIVITY__TOOLS:
				return ((InternalEList<?>)getTools()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case SpemPackage.ACTIVITY__WPS:
				return getWps();
			case SpemPackage.ACTIVITY__TS:
				return getTs();
			case SpemPackage.ACTIVITY__RS:
				return getRs();
			case SpemPackage.ACTIVITY__TOOLS:
				return getTools();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case SpemPackage.ACTIVITY__WPS:
				getWps().clear();
				getWps().addAll((Collection<? extends WorkProductDefinition>)newValue);
				return;
			case SpemPackage.ACTIVITY__TS:
				getTs().clear();
				getTs().addAll((Collection<? extends TaskDefinition>)newValue);
				return;
			case SpemPackage.ACTIVITY__RS:
				getRs().clear();
				getRs().addAll((Collection<? extends RoleDefinition>)newValue);
				return;
			case SpemPackage.ACTIVITY__TOOLS:
				getTools().clear();
				getTools().addAll((Collection<? extends Tool>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case SpemPackage.ACTIVITY__WPS:
				getWps().clear();
				return;
			case SpemPackage.ACTIVITY__TS:
				getTs().clear();
				return;
			case SpemPackage.ACTIVITY__RS:
				getRs().clear();
				return;
			case SpemPackage.ACTIVITY__TOOLS:
				getTools().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case SpemPackage.ACTIVITY__WPS:
				return wps != null && !wps.isEmpty();
			case SpemPackage.ACTIVITY__TS:
				return ts != null && !ts.isEmpty();
			case SpemPackage.ACTIVITY__RS:
				return rs != null && !rs.isEmpty();
			case SpemPackage.ACTIVITY__TOOLS:
				return tools != null && !tools.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //ActivityImpl
